import {CanActivateFn, Router} from "@angular/router";
import {AuthService} from "../service/auth.service";
import {inject} from "@angular/core";
import {OAuthService} from "angular-oauth2-oidc";

export function AuthGuard(): CanActivateFn {

  return () => {
    const authService: AuthService = inject(AuthService)
    const oauthService: OAuthService= inject(OAuthService)
    const router: Router = inject(Router)

    if (oauthService.hasValidAccessToken()) {
      return true
    }
    // router.navigate(['/'])
    return false
  }

}
